package com.aidansmeaton.weightmanager;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

/** The first activity in the app. */
public class FeedbackActivity extends Activity {
	
	// Personal
	private EditText message;
    
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    	setContentView(R.layout.feedback);
    	
        String name = getSharedPreferences("Profile", 0).getString("Name","");
        String hint = (name.length()>0) ? "Hey "+name+"! :)\n\n" : "Hey! :)\n\n";
        
        message = (EditText) findViewById(R.id.message);
        message.setHint(hint+getString(R.string.feedback_hint));
        
    }
	
	public void sendClick(View v){
		String text = message.getText().toString();
		if (text.toString().length()>0){
			finish();
			Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
	        emailIntent.setType("plain/text");
	        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ "aa.smeaton@gmail.com" });
	        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Weight Manager Feedback");
	        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
	        FeedbackActivity.this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
		}
		else {
			Toast.makeText(this, "First, type in a message to send.", Toast.LENGTH_SHORT).show();
		}
	}
	
	public void cancelClick(View v){
		finish();
	}
	
}